package com.shiwaixiangcun.customer.glide;

import android.content.Context;
import android.graphics.Color;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.shiwaixiangcun.customer.R;
import com.shiwaixiangcun.customer.utils.DisplayUtil;
import com.shiwaixiangcun.customer.widget.RoundImageView;
import com.shiwaixiangcun.customer.widget.bannerview.loader.ImageLoader;

/**
 * Author   Administrator
 * Date     2018/2/2
 * Desc     Banner图片加载
 *
 * @author xujhin
 */

public class BannerImageLoader extends ImageLoader {
    @Override
    public void displayImage(Context context, Object path, ImageView imageView) {
        Glide.with(context)
                .load(path.toString())

                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .error(R.drawable.image_error)
                .into(imageView);
    }

    @Override
    public ImageView createImageView(Context context) {
        RoundImageView imageView = new RoundImageView(context);
        imageView.setBorderColor(Color.WHITE);
        imageView.setBorderCorner(DisplayUtil.INSTANCE.dip2px(context, 2));
        imageView.setBorderWidth(0);
        imageView.setType(1);
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        return imageView;
    }
}